#include "drv_systick.h"
static uint16_t fs_us=0;
static uint16_t fs_ms=0;
void drv_systick_init(uint8_t systick)
{
	SysTick->CTRL &= ~0x05;
	fs_us = systick/8;//计1us需要计次数
	fs_ms = fs_us*1000;////计1ms需要计次数
}

void drv_systick_ms(uint16_t ms)
{
	uint32_t temp=0;
	uint8_t systick_flag=0;
	while(systick_flag == 0)
	{
		if(ms>798)
		{
			SysTick->LOAD = fs_ms*798;
			ms = ms-798;
		}
		else
		{
			SysTick->LOAD = fs_ms*ms;
			systick_flag = 1;
		}
		SysTick->CTRL |= 0x01;
		do
		{
			temp = SysTick->CTRL;
		}
		while (!(temp&(0x01<<16)));
		SysTick->CTRL &= ~0x01;
		SysTick->VAL = 0;
	}
	
}
